<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

</body>
<script>
  var maxDistance = function (nums1, nums2) {
    let i = nums1.length - 1;
    let j = nums2.length - 1;
    let max = 0;
    while (j >= 0) {
      while (nums1[i] <= nums2[j]) {
        max = Math.max(max, j - i);
        i--;
      }
      j--;
    }
    return max;
  };
  console.log(arr());
</script>

</html>